package com.androwit.engine.mapping.converter.str;

import java.util.HashMap;
import java.util.Map;

public class EnumLabellerImpl<T extends Enum<T>> implements EnumLabeller<T> {
	protected Map<T, String> map = new HashMap<T, String>();

	public EnumLabellerImpl(T[] enums, String... labels) {
		if (enums.length != labels.length)
			throw new IllegalArgumentException(
					"enums must be the same size as labels");

		for (int i = 0; i < labels.length; i++) {
			map.put(enums[i], labels[i]);
		}
	}

	@Override
	public String getLabel(T enumItem) {
		return map.get(enumItem);
	}

}
